package com.ykdl.app.view;

import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.TextView;

import com.ykdl.app.R;
import com.ykdl.app.Utils.ScreenUtilsProvider;

public class ShareDialogCommon {
	
	public ShareDialogCommon() {
		// TODO Auto-generated constructor stub
	}
	
	private Dialog mGoodDialog;
	/**
	 * 
	 * @param context 环境变量--activity
	 * @param title 标题
	 * @param content1 内容1
	 * @param content2 内容2
	 * @param isSingle 是否单个拍照--用于一个类中 有两个地方需要拍照选择的，true,单个，false 多个
	 * @param onFirstListener 第一个为
	 * @param onNextListener
	 */
	public void showImageDiaog(Activity context,
			String title,
			String content1,
			String content2,
			final boolean isSingle,
			final onFirstListener first,
			final onNextListener	next ,
			final OnDismissListener mlistener
			){
			mGoodDialog = new Dialog(context, R.style.bubble_dialog);
			mGoodDialog.setCanceledOnTouchOutside(true);
			Window dialogWindow = mGoodDialog.getWindow();
			WindowManager manager = context.getWindowManager();
			LayoutParams params = dialogWindow.getAttributes();// 获取LayoutParams
			dialogWindow.setGravity(Gravity.BOTTOM);
			
			params.width = ScreenUtilsProvider.screenWidth;
			dialogWindow.setAttributes(params);
			mGoodDialog.setContentView(R.layout.fragment_dialog_select_image);
			mGoodDialog.show();
			TextView camera = (TextView) mGoodDialog.findViewById(R.id.tv_common_goods);
			camera.setText("拍照");
			camera.setOnClickListener(new OnClickListener() {	
				@Override
				public void onClick(View v) {
					
					first.onClick(v, isSingle);
					mGoodDialog.dismiss();
				}
			});
			
			TextView mPhoto = (TextView) mGoodDialog.findViewById(R.id.tv_limit);
			mPhoto.setText("相册");
			mPhoto.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					
					next.onClick(v, isSingle);
					mGoodDialog.dismiss();
				}
			});
			TextView mtitle = (TextView) mGoodDialog.findViewById(R.id.title);
			mtitle.setText("请选择照片");
			
			mGoodDialog.setOnDismissListener(new OnDismissListener() {
				
				@Override
				public void onDismiss(DialogInterface dialog) {
					
					mlistener.onDismiss(dialog);
				}
			});

	}
	
	
	
	public interface onFirstListener{
		void onClick(View v,boolean isSingle);
	}
	public interface onNextListener{
		void onClick(View v,boolean isSingle);
	}
}
